<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="generator" content="MATLAB R2017b"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><title>Derivation of the stiffness matrix of a 2-node bar element</title><style type="text/css">
* {margin: 0; padding: 0;}
body {text-align: start; line-height: 17.234001159668px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-style: normal; font-size: 14px; font-weight: normal; text-decoration: none; white-space: normal; }
h1, h2 {font-weight: normal;}
.content { padding: 30px; }

.S0 { margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px;  }
.S1 { text-align: left; line-height: 26.3999996185303px; min-height: 24px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-size: 22.0000019073486px; white-space: pre-wrap; margin-left: 4px; margin-top: 3px; margin-bottom: 15px; margin-right: 10px;  }
.S2 { min-height: 0px; margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px;  }
.S3 { text-align: left; line-height: 20.576000213623px; min-height: 20px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-size: 16px; font-weight: bold; white-space: pre-wrap; margin-left: 4px; margin-top: 3px; margin-bottom: 9px; margin-right: 10px;  }
.S4 { margin-left: 3px; margin-top: 10px; margin-bottom: 4px; margin-right: 3px;  }
.S5 { min-height: 18px; white-space: nowrap; white-space: nowrap; margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px;  }
.S6 { min-height: 0px; white-space: pre; white-space: pre; margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 45px;  }
.S7 { color: rgb(34, 139, 34); margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px;  }
.S8 { color: rgb(160, 32, 240); margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px;  }
.S9 { color: rgb(64, 64, 64); margin-left: 0px; margin-top: 0px; margin-bottom: 0px; margin-right: 0px;  }
.S10 { margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px;  }
.S11 { text-align: left; line-height: 26.3999996185303px; min-height: 24px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-size: 22.0000019073486px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 15px; margin-right: 10px;  }

.CodeBlock {margin: 10px 0 10px 0; background-color: #F7F7F7;}
.CodeBlock+.paragraphNode {margin-top: 10px;}
.lineNode {padding-left: 10px; border-left: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9;}
.inlineWrapper:first-child .lineNode,.inlineWrapper.outputs+.inlineWrapper .lineNode {padding-top: 5px; border-top: 1px solid #E9E9E9;}
.inlineWrapper:last-child .lineNode,.inlineWrapper.outputs .lineNode {padding-bottom: 5px; border-bottom: 1px solid #E9E9E9;}
.lineNode .textBox {white-space: pre;}
.outputGroup {margin: 2px 0 2px 0; padding: 2px 2px 2px 4px;}
.outputRegion {}
.outputParagraph {color: rgba(64, 64, 64, 1); padding: 10px 0 6px 17px; background: white; overflow-x: hidden;}
.inlineWrapper:last-child .outputParagraph {border-bottom-left-radius: 4px; border-bottom-right-radius: 4px;}
.outputParagraph:empty {margin: 0;}
.inlineElement .symbolicElement {margin-top: 1px; margin-bottom: 1px;}
.embeddedOutputsSymbolicElement .MathEquation {margin-top: 4px; margin-bottom: 4px;}
.embeddedOutputsSymbolicElement .MathEquation.displaySymbolicElement {margin-left: 15px;}
.embeddedOutputsSymbolicElement .MathEquation.inlineSymbolicElement {}
.embeddedOutputsSymbolicElement {overflow-x: auto; overflow-y: auto;}
.embeddedOutputsSymbolicElement { overflow: initial !important;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {white-space: pre; word-wrap: initial; min-height: 18px; max-height: 250px; overflow: auto;}
.textElement,.rtcDataTipElement .textElement {padding-top: 3px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement { max-height: none !important; overflow: initial !important;}
.veSpecifier {}
.veContainer {}
.veSpecifierBox {height: 400px; width: 500px;}
.veSpecifier .veTable {padding-top: 3px; padding-bottom: 4px;}
.veSpecifierBox .veSpecifier .veContainer {position: relative; width: 100%; height: 370px;}
.veSpecifierBox .dijitDialogPaneContent {width: 97% !important; height: 88% !important;}
.veSpecifier .veTable .rowHeadersWrapper {padding-bottom: 0;}
.veSpecifier .veTable .scroller .variableEditorRenderers {padding-right: 3px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none;}
.veSpecifier .veTable .topHeaderWrapper,.veSpecifier .veTable .bottomRowHeaderWrapper {visibility: hidden; z-index: 0;}
.veMetaSummary {font-style: italic;}
.veSpecifier .veTable .scroller {overflow: hidden;}
.veSpecifier .veTable:hover .scroller {overflow: auto;}
.veSpecifier .veVariableName,.veSpecifier .veDimensionFont {font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px;}
.veSpecifier .veVariableName {padding-top: 2px;}
.veSpecifier .veDimensionFont {font-style: italic; color: #9A9A9A;}
.veSpecifier .scroller::-webkit-scrollbar-track {background-color: white;}
.veSpecifier .scroller::-webkit-scrollbar-corner {background-color: white;}
.veSpecifier .veTable .topRowHeaderWrapper {border: none; background-color: #F8F9FA;}
.veSpecifier .mw_type_ListBase.showCellBorders,.veSpecifier .veTable .topHeaderWrapper,.veSpecifier .veTable .bottomRowHeaderWrapper,.veSpecifier .veTable .verticalScrollSpacer,.veSpecifier .veTable .horizontalScrollSpacer {border: none;}
.veSpecifier .veTable .dataScrollerNode {border: 1px solid #BFBFBF;}
.veSpecifier .veTable .columnHeaderNode,.veSpecifier .veTable .rowHeaderNode,.veSpecifier .veTable .dataBody {font-family: Arial; font-size: 13px;}
.veSpecifier .veTable .columnHeaderNode,.veSpecifier .veTable .rowHeaderNode {color: #7F7F7F;}
.veSpecifier .veTable .dataBody {color: #000000;}
.veSpecifier .veTable .columnHeaderNode .cell .drag,.veSpecifier .veTable .columnHeaderNode .cell .header,.veSpecifier .veTable .topHeaderWrapper,.veSpecifier .veTable .bottomRowHeaderWrapper {background-color: #F8F9FA;}
.veSpecifier .veTable .columnHeaderNode .cell .dragBorder {border-right: 1px solid #F8F9FA;}
.veSpecifier .veTable .rowHeaderNode .cell {padding-top: 3px; text-align: center; border-bottom: 1px solid #F8F9FA;}
.veSpecifier .veTable .dataBody .cell .plainText {text-align: right;}
.veSpecifier .veTable .dataBody .row .cell {border-bottom: 1px solid #E9E9E9; border-right: 1px solid #E9E9E9;}
.embeddedOutputsVariableElement {white-space: pre-wrap; word-wrap: break-word; min-height: 18px; max-height: 250px; overflow: auto;}
.variableElement {}
.embeddedOutputsVariableElement.inlineElement {}
.inlineElement .variableElement {}
.variableNameElement {margin-bottom: 3px; display: inline-block;}
.variableValue { width: 100% !important; }
.embeddedOutputsMatrixElement {min-height: 18px; box-sizing: border-box;}
.embeddedOutputsMatrixElement .matrixElement,.rtcDataTipElement .matrixElement {position: relative;}
.matrixElement .variableValue,.rtcDataTipElement .matrixElement .variableValue {white-space: pre; display: inline-block; vertical-align: top; overflow: hidden;}
.embeddedOutputsMatrixElement.inlineElement {}
.embeddedOutputsMatrixElement.inlineElement .topHeaderWrapper {display: none;}
.embeddedOutputsMatrixElement.inlineElement .veTable .body {padding-top: 0 !important; max-height: 100px;}
.inlineElement .matrixElement {max-height: 300px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer,.rtcDataTipElement .matrixElement .valueContainer {white-space: nowrap; margin-bottom: 3px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis.hide,.embeddedOutputsMatrixElement .matrixElement .verticalEllipsis.hide,.rtcDataTipElement .matrixElement .valueContainer .horizontalEllipsis.hide,.rtcDataTipElement .matrixElement .verticalEllipsis.hide {display: none;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis {margin-bottom: -3px;}
.matrixElement { max-height: none !important; }
.embeddedOutputsVariableTableElement .ClientViewDiv table tr {height: 22px; white-space: nowrap;}
.embeddedOutputsVariableTableElement .ClientViewDiv table thead tr th {border-width: 1px 0px 1px 1px;}
.embeddedOutputsVariableTableElement .ClientViewDiv table {border-spacing: 0px; border: 1px solid #bfbfbf; border-width: 0px 1px 0px 0px;}
.embeddedOutputsVariableTableElement .ClientViewDiv table tr td,.embeddedOutputsVariableTableElement .ClientViewDiv table tr th {min-width : 75px; max-width : 75px; background-color:white; border: 1px solid #bfbfbf; text-overflow: ellipsis; border-width: 0px 0px 1px 1px; font-family: 'Arial', sans-serif; font-size: 12px; overflow : hidden;}
.embeddedOutputsVariableTableElement .ClientViewDiv table tbody tr th {width: 34px; max-width: 100px;}
.embeddedOutputsVariableTableElement .ClientViewDiv table tr span {text-overflow: ellipsis; padding: 3px;}
.embeddedOutputsVariableTableElement .ClientViewDiv table tr th {background: #f5f5f5; color: rgba(0,0,0,0.5); padding: 3px; font-size: 9px;}
.embeddedOutputsVariableTableElement .ClientViewDiv table tr th:first-child {min-width: 28px; max-width: 250px;}
.dijitTooltipDialog .dijitTooltipContainer .dijitTooltipContents .alertPlugin-alertMessage {min-width: 12px; max-width: 400px; max-height: 300px; overflow: auto;}
.dijitTooltipDialog .alertPlugin-alertMessage::-webkit-scrollbar {width: 11px; height: 11px;}
.dijitTooltipDialog .alertPlugin-alertMessage::-webkit-scrollbar-track {background-color: rgba(0, 0, 0, 0);}
.dijitTooltipDialog .alertPlugin-alertMessage::-webkit-scrollbar-corner {background-color: rgba(0, 0, 0, 0);}
.dijitTooltipDialog .alertPlugin-alertMessage::-webkit-scrollbar-thumb {border-radius: 7px; background-color: rgba(0, 0, 0, 0.1); border: 2px solid rgba(0, 0, 0, 0); background-clip: padding-box;}
.dijitTooltipDialog .alertPlugin-alertMessage::-webkit-scrollbar-thumb:hover {background-color: rgba(0, 0, 0, 0.2);}
.dijitTooltipDialog .alertPlugin-alertMessage::-webkit-scrollbar-thumb {background-color: rgba(0, 0, 0, 0);}
.dijitTooltipDialog .alertPlugin-alertMessage:hover::-webkit-scrollbar-thumb {background-color: rgba(0, 0, 0, 0.1);}
.dijitTooltipDialog .alertPlugin-alertMessage:hover::-webkit-scrollbar-thumb:hover {background-color: rgba(0, 0, 0, 0.2);}
.alertPlugin-alertLine {position: absolute; display: initial; width: 40px; text-align: right; cursor: text;}
.alertPlugin-onTextLine {visibility: hidden;}
.alertPlugin-hasTooltip .alertPlugin-warningImg,.alertPlugin-hasTooltip .alertPlugin-errorImg {cursor: pointer;}
.alertPlugin-alertLine .alertPlugin-warningElement,.alertPlugin-alertLine .alertPlugin-errorElement {display: inline-block; margin-right: 4px;}
.alertPlugin-isStale {-webkit-filter: opacity(0.4) grayscale(80%); filter: opacity(0.4) grayscale(80%);}
.diagnosticMessage-wrapper {font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType {color: rgb(255,100,0);}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a {color: rgb(255,100,0); text-decoration: underline;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType {color: rgb(230,0,0);}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a {color: rgb(230,0,0); text-decoration: underline;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart {white-space: pre-wrap;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart {white-space: pre;}
.embeddedOutputsWarningElement{min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsErrorElement {min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsErrorElement.inlineElement {}
.variableNameElement .headerElement {color: rgb(179, 179, 179); font-style: italic;}
.variableNameElement .headerElement .headerDataType {color: rgb(147, 176, 230);}
.matrixElement .horizontalEllipsis,.rtcDataTipElement .matrixElement .horizontalEllipsis {display: inline-block; margin-top: 3px; content: url("");}
.matrixElement .verticalEllipsis,.textElement .verticalEllipsis,.rtcDataTipElement .matrixElement .verticalEllipsis,.rtcDataTipElement .textElement .verticalEllipsis {margin-left: 35px; content: url("");}
</style></head><body><div class = "content"><div class = 'SectionBlock containment active'><h1 class = "S1"><span class = "S2"><span class="S0">Derivation of the stiffness matrix of a 2-node bar element</span></span></h1></div><div class = "S0"></div><div class = 'SectionBlock containment'><h2 class = "S3"><span class = "S2"><span class="S0">Clean up</span></span></h2><div class = 'CodeBlock contiguous'><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S0"></span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S7">%clear workspace</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S0">clear </span><span class="S8">all</span><span class="S0">;</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S7">%clear command window</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S0">clc;</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S7">%clear figures</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S0">clf;</span></span></div></div></div></div><div class = "S0"></div><div class = 'SectionBlock containment'><h2 class = "S3"><span class = "S2"><span class="S0">Define symbolic quantities</span></span></h2><div class = 'CodeBlock contiguous'><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S0">syms </span><span class="S8">r x L</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S0">syms </span><span class="S8">E_mod A_sec</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S0">syms </span><span class="S8">q</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S7">%the derived quantities will automatically be initialized as symbolic variables as well</span></span></div></div><div class = 'inlineWrapper'><div class = "S5 lineNode"><span class = "S6"><span class="S0"></span></span></div></div></div></div><div class = "S0"></div><div class = 'SectionBlock containment'><h2 class = "S3"><span class = "S2"><span class="S0">Derive shape functions N</span></span></h2><div class = 'CodeBlock contiguous'><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">A = [1,r]</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="8AFB2357" data-testid="output_0" data-width="281" data-height="27" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">A =&nbsp;</span><span class="MathEquation inlineSymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -5px;"><img src="" width="41" height="18"></span></span></div></div></div></div><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">E = [1,-1;1,1]</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement scrollableOutput" uid="127E18EB" data-testid="output_1" data-width="281" data-height="49" style="width: 311px; max-height: 261px; white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">E = </span></div><div style="white-space: pre; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    1.00000000000000e+000   -1.00000000000000e+000
    1.00000000000000e+000    1.00000000000000e+000
</div></div></div></div></div><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">N = A*E^-1</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="1004BCEE" data-testid="output_2" data-width="281" data-height="63" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">N =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -15px;"><img src="" width="97" height="36"></span></span></div></div></div></div></div></div><div class = "S0"></div><div class = 'SectionBlock containment'><h2 class = "S3"><span class = "S2"><span class="S0">Derive strain-displacement matrix B</span></span></h2><div class = 'CodeBlock contiguous'><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">Jac = diff(2*x/L-1,x)</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="4FFCCF6A" data-testid="output_3" data-width="281" data-height="62" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Jac =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -15px;"><img src="" width="13" height="34"></span></span></div></div></div></div><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">det_Jac = Jac^-1</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="D21B31F8" data-testid="output_4" data-width="281" data-height="62" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">det_Jac =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -15px;"><img src="" width="13" height="34"></span></span></div></div></div></div><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">B = diff(N)*Jac</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="60211F55" data-testid="output_5" data-width="281" data-height="63" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">B =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -15px;"><img src="" width="65.5" height="36"></span></span></div></div></div></div></div></div><div class = "S0"></div><div class = 'SectionBlock containment'><h2 class = "S3"><span class = "S2"><span class="S0">Construct stiffness matrix</span></span></h2><div class = 'CodeBlock contiguous'><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">K_2node = E_mod * A_sec * int(B'*B,r,-1,1)*det_Jac</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement scrollableOutput" uid="518D9748" data-testid="output_6" data-width="281" data-height="113" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">K_2node =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -37px;"><img src="" width="170.5" height="84"></span></span></div></div></div></div><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">matrix_factor = gcd(K_2node), K_2node/matrix_factor</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="81A05D57" data-testid="output_7" data-width="281" data-height="66" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">matrix_factor =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -17px;"><img src="" width="55" height="38"></span></span></div></div><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="37D9951D" data-testid="output_8" data-width="281" data-height="66" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -14px;"><img src="" width="72.5" height="39"></span></span></div></div></div></div></div></div><div class = "S0"></div><div class = 'SectionBlock containment'><h2 class = "S3"><span class = "S2"><span class="S0">Construct loading vector</span></span></h2><div class = 'CodeBlock contiguous'><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">F_2node = int(N'*q,r,-1,1)*det_Jac</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="2FB73C8E" data-testid="output_9" data-width="281" data-height="102" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">F_2node =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -32px;"><img src="" width="49.5" height="74.5"></span></span></div></div></div></div><div class = 'inlineWrapper outputs'><div class = "S5 lineNode"><span class = "S6"><span class="S0">vector_factor = gcd(F_2node), F_2node/vector_factor</span></span></div><div class="outputParagraph" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 14px;"><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="4B455987" data-testid="output_10" data-width="281" data-height="62" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">vector_factor =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -15px;"><img src="" width="23.5" height="34"></span></span></div></div><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="CC8B5E7F" data-testid="output_11" data-width="281" data-height="66" style="width: 311px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="symbolicElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="embeddedOutputsVariableElement" style="white-space: pre-wrap; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px; white-space: nowrap; font-style: normal; color: rgb(64, 64, 64);"><span style="vertical-align: -14px;"><img src="" width="32.5" height="39"></span></span></div></div></div></div></div><h1 class = "S11"><span class = "S2"><span class="S0"></span></span></h1></div></div>
<!-- 
##### SOURCE BEGIN #####
%% Derivation of the stiffness matrix of a 2-node bar element
%% Clean up
%%

%clear workspace
clear all;
%clear command window
clc;
%clear figures
clf;
%% Define symbolic quantities
%%
syms r x L
syms E_mod A_sec
syms q
%the derived quantities will automatically be initialized as symbolic variables as well

%% Derive shape functions N
%%
A = [1,r]
E = [1,-1;1,1]
N = A*E^-1
%% Derive strain-displacement matrix B
%%
Jac = diff(2*x/L-1,x)
det_Jac = Jac^-1
B = diff(N)*Jac
%% Construct stiffness matrix
%%
K_2node = E_mod * A_sec * int(B'*B,r,-1,1)*det_Jac
matrix_factor = gcd(K_2node), K_2node/matrix_factor
%% Construct loading vector
%%
F_2node = int(N'*q,r,-1,1)*det_Jac
vector_factor = gcd(F_2node), F_2node/vector_factor
%%
##### SOURCE END #####
--></body></html>